package com.lqq.controller.restfull;

import com.github.pagehelper.PageInfo;
import com.lqq.dto.UserDetailDto;
import com.lqq.entity.User;
import com.lqq.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author qingqing.liang
 * @create 2018-01-30
 **/
@RestController
@RequestMapping("/user")
@Api(description = "单表查询")
public class UserController {

    @Autowired
    private UserService userService;


    @RequestMapping("/getById")
    @ApiOperation(value = "根据id查询User信息",httpMethod = "GET")
    public User getById(@RequestParam @ApiParam(required = true,defaultValue = "1") Long id){
        User user = userService.getById(id);
        return user;
    }




    @RequestMapping("/getUsers")
    @ApiOperation(value = "分页查询",httpMethod = "GET")
    public PageInfo<User> getUsers(@RequestParam @ApiParam(required = true,defaultValue = "1") int currentPage,
                                   @RequestParam @ApiParam(required = true,defaultValue = "3") int pageSize){
        return userService.getUsers(pageSize,currentPage);
    }



}
